package com.tank.collision;

import com.almasb.fxgl.dsl.FXGL;
import com.almasb.fxgl.entity.Entity;
import com.almasb.fxgl.physics.CollisionHandler;
import com.tank.TankApp;
import com.tank.components.BaseComponent;
import com.tank.constant.Config;
import com.tank.constant.GameType;
import com.tank.ui.FailedScene;

public class BulletBaseCollideHandler extends CollisionHandler {
    public BulletBaseCollideHandler() {
        super(GameType.BULLET, GameType.BASE);
    }

    @Override
    protected void onCollisionBegin(Entity bullet, Entity base) {
        base.getComponent(BaseComponent.class).onHit();
        FXGL.spawn("doomExplosion", bullet.getCenter().subtract(50 / 2.0, 50 / 2.0));
        bullet.removeFromWorld();
        FXGL.<TankApp>getAppCast().fail();
    }
}
